import java.util.Scanner;

public class Main {

 /**
 * @param args
 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int MAX = 0;
		int MIN;
		String kolMAX = null;
		String kolMIN = null;
		System.out.println("Vvedite kolichestvo strok");
		int kolichestvo = sc.nextInt();
		String mass[] = new String[kolichestvo];
		System.out.println("Vvedite stroki");
		for (int i = 0; i < mass.length; i++) 
		{
			mass[i] = sc.next();
		}
		MIN = mass[0].length();
		for (int i = 0; i < mass.length; i++) {
			if (mass[i].length() > MAX) {
				MAX = mass[i].length();
				kolMAX = mass[i];
			}
		}
		for (int i = 0; i < mass.length; i++) {
			if (mass[i].length() < MIN) {
				MIN = mass[i].length();
				kolMIN = mass[i];
			}
		}
		System.out.println(MAX + " " + kolMAX + " " + MIN + " " + kolMIN);
	}

}